﻿@namespace SatelliteSite.StudentModule.Panels
@using SatelliteSite.StudentModule.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, SatelliteSite.Substrate
@model TenantAssignModel
@{
    Layout = "_WindowLayout";
    ViewData["Title"] = "Assign tenant administrator";
}

<div class="form-group">
    <label asp-for="UserName"></label>
    <input asp-for="UserName" onblur="oncheck($(this).val())" class="form-control" required />
    <small id="tryUser" class="text-danger"></small>
</div>

@section Footer {
    <button asp-action="Assign" type="submit" class="btn btn-primary">Save</button>
}

@section Scripts {
    <script>
        function oncheck(val) {
            if (val === '') {
                $('#tryUser').text('Please enter the username.');
            } else if (val.indexOf('/') !== -1 || val.indexOf('#') !== -1 || val.indexOf('?') !== -1) {
                $('#tryUser').text('Please enter a valid username.');
            } else {
                ajaxget('@Url.Action("TestUser", new { userName = "_USER_NAME_" })'.replace('_USER_NAME_', val),'#tryUser')
            }
        }
    </script>
}
